<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags always come first -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css">
    <title>Git View v1.0 - Branch Management Tools for QA</title>
</head>
<body>

<div class="container">

    <div class="row">

        <div class="col-lg-12">

            <div class="alert alert-info">
                <h1>Git View</h1>
                <p>Branch Management Tools for QA</p>
            </div>

            <!-- project list-->
            <div class="alert alert-success">
                Projects:
               <?php foreach($projects as $p) { ?>
               <a href="/?prj={{$p}}"><span class="label {{ $p==$prj?'label-danger':'label-primary' }}">{{$p}}</span></a>
               <?php } ?>
            </div>
            <!-- end project list-->

            <h3>Local Branches</h3>

            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th></th>
                        <th>Branch</th>
                        <th>Commit</th>
                        <th>Message</th>
                        <th>Actions</th>
                        <th>Actions</th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach($local_branches as $lb) { ?>
                        <?php if( $lb['name']==$current_branch ) { ?>
                        <tr>
                            <td>
                                <span class="label label-danger">*</span>
                            </td>
                            <td>{{ $lb['name'] }}</td>
                            <td>{{ $lb['commit'] }}</td>
                            <td width="40%">{{ $lb['message'] }}</td>
                            <td>
                                <a href="javascript:;" class="btn btn-primary disabled">Active</a>
                                <a href="/cmd?prj={{$prj}}&cmd=pull&br={{$lb['name']}}" class="btn btn-success">Update</a>
                                <a href="/cmd?prj={{$prj}}&cmd=copy&br={{$lb['name']}}" class="btn btn-info">Copy</a>
                            </td>
                            <td>
                                <a href="javascript:;" class="btn btn-danger disabled">Delete</a>
                            </td>
                        </tr>
                        <?php } else { ?>
                        <tr>
                            <td></td>
                            <td>{{ $lb['name'] }}</td>
                            <td>{{ $lb['commit'] }}</td>
                            <td width="40%">{{ $lb['message'] }}</td>
                            <td>
                                <a href="/cmd?prj={{$prj}}&cmd=active&br={{$lb['name']}}" class="btn btn-primary">Active</a>
                                <a href="/cmd?prj={{$prj}}&cmd=pull&br={{$lb['name']}}" class="btn btn-success">Update</a>
                                <a href="/cmd?prj={{$prj}}&cmd=copy&br={{$lb['name']}}" class="btn btn-info">Copy</a>
                            </td>
                            <td>
                                <a href="/cmd?prj={{$prj}}&cmd=delete&br={{$lb['name']}}" class="btn btn-danger">Delete</a>
                            </td>
                        </tr>
                     <?php } } ?>
                </tbody>
            </table>

            <hr/>

            <h3>Remote Branches</h3>
            <p><a href="/cmd?prj={{$prj}}&cmd=fetch" class="btn btn-primary btn-sm">Update</a></p>

            <table class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>Branch</th>
                    <th>Commit</th>
                    <th>Message</th>
                    <th>Actions</th>
                </tr>
                </thead>

                <tbody>
                <?php foreach($remote_branches as $rb) { ?>
                <tr>
                    <td>origin/{{ $rb['name'] }}</td>
                    <td>{{ $rb['commit'] }}</td>
                    <td width="40%">{{ $rb['message'] }}</td>
                    <td>
                        <a href="/cmd?prj={{$prj}}&cmd=checkout&br={{$rb['name']}}" class="btn btn-secondary">Checkout</a>
                    </td>
                </tr>
                <?php } ?>
                </tbody>
            </table>
            
        </div>
    </div><!-- row -->

    <div class="row">
        <div class="col-lg-12">
            <hr/>
            <p class="text-center">&copy; 2015-{{date('Y')}} TXCAP Powered by Hans</p>
        </div>
    </div>
</div>


<!-- jQuery first, then Bootstrap JS. -->
<script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
</body>
</html>